local skel = fk.CreateSkill {
  name = "emo__quai",
}

skel:addEffect(fk.EnterDying, {
  anim_type = "support",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and target ~= player and target.hp < 1
  end,
  on_cost = function (self, event, target, player, data)
    if player.room:askToSkillInvoke(player, {skill_name = skel.name, prompt = "#emo__quai-invoke:"..target.id}) then
      event:setCostData(self, {tos = {target}})
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, 1)
    room:recover { num = 1 - target.hp, skillName = skel.name, who = target, recoverBy = player }
    if player.dead then return end
    local n = 0
    if not target.dead and not target:isNude() then
      local cards = room:askToDiscard(target, {
        min_num = 1, max_num = 2, skill_name = skel.name, pattern = ".|.|spade,club", cancelable = true, include_equip = true,
        prompt = "#emo__quai-discard::"..player.id..":2"
      })
      n = #cards
    end
    if not player.dead and not player:isNude() and n < 2 then
      local cards = room:askToDiscard(player, {
        min_num = (2 - n), max_num = (2 - n), skill_name = skel.name, pattern = ".|.|spade,club", cancelable = true, include_equip = true,
        prompt = "#emo__quai-discard::"..player.id..":"..(2 - n)
      })
      n = #cards + n
    end
    if not player.dead and n < 2 then
      room:loseHp(player, 2, skel.name)
    end
  end,
})


Fk:loadTranslationTable{
  ["emo__quai"] = "去爱",
  [":emo__quai"] = "当其他角色进入濒死阶段时，你可以增加一点体力上限并令其回复体力至一点，然后其与你需弃置共两张黑色牌，否则你失去2点体力。",
  ["#emo__quai-invoke"] = "去爱：你可以令 %src 回复体力至一点",
  ["#emo__quai-discard"] = "去爱：你需弃置 %arg 张黑色牌，否则 %dest 失去2点体力",
}

return skel
